<%@ page language="java"  pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<title>新闻发布系统管理后台</title>

<link href="news/css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function check(){
		var ntitle = document.getElementById("ntitle");
		var nauthor = document.getElementById("nauthor");
		var nsummary = document.getElementById("nsummary");
		var ncontent = document.getElementById("ncontent");
		
		if(ntitle.value == ""){
			alert("标题不能为空！！");
			ntitle.focus();
			return false;
		}else if(nauthor.value == ""){
			alert("作者不能为空！！");
			nauthor.focus();
			return false;
		}else if(nsummary.value == ""){
			alert("摘要不能为空！！");
			nsummary.focus();
			return false;
		}else if(ncontent.value == ""){
			alert("内容不能为空！！");
			ncontent.focus();
			return false;
		}		
		return true;
	}
</script>
</head>
<body>
<jsp:include page="/AdminHeaderServlet"></jsp:include>
<div id="main">
  <jsp:include page="/AdminLeftServlet"></jsp:include>

  <div id="opt_area">
    <h1 id="opt_type">修改新闻： </h1>
    <form action="DoModifyNewsServlet"  enctype="multipart/form-data" method="post"  onsubmit="return check()">
      <p>
        <label> 主题 </label>
        <select name="ntid" >
        <c:forEach items="${listTopic}" var="t" >
        	<option value="${t.tid}" ${t.tid==news.ntid?"selected":"" }>
        		${t.tname}
        	</option>
        </c:forEach>
        </select>
        <input type="hidden" name="nid" value="${news.nid}" />
      </p>
      <p>
        <label> 标题 </label>
        <input name="ntitle" id="ntitle" type="text" class="opt_input" value="${news.ntitle}"/>
      </p>
      <p>
        <label> 作者 </label>
        <input name="nauthor" id="nauthor" type="text" class="opt_input" value="${news.nauthor}"/>
      </p>
      <p>
        <label> 摘要 </label>
        <textarea name="nsummary" id="nsummary" cols="40" rows="3" value="">${news.nsummary}</textarea>
      </p>
      <p>
        <label> 内容 </label>
        <textarea name="ncontent" id="ncontent" cols="70" rows="10" value="">${news.ncontent}</textarea>
      </p>
      <p  >
        <label> 上传图片 </label>
        <input style="height:25px;"  name="file" id="file" type="file" class="opt_input" />
        <c:choose>
        	<c:when test="${news.npicPath==null||news.getNpicPath().equals('')}">
        		 <img src="news/images/index.gif"  id="pic" style="height:100px;width:130px"  >
        	</c:when> 
        	<c:otherwise>
        		<img src="news/${news.npicPath}"  id="pic" style="height:100px;width:130px"  >
        	</c:otherwise>	
         </c:choose>
      </p>
     <%--  ${(news.npicPath==null||news.getNpicPath().equals(''))?'news/images/index.gif':'news/${news.npicPath}'} --%>
      <script type="text/javascript">
					 var x=new FileReader;
							document.getElementById("file").onchange=function(){
							  x.readAsDataURL(this.files[0]);
					 }
						 x.onloadend=function(){
						  document.getElementById("pic").src=this.result;
					 }
		</script>
      <input type="submit" value="提交" class="opt_sub" />
      <input type="reset" value="重置" class="opt_sub" />
    </form>
    <h1 id="opt_type">
		修改新闻评论：
	</h1>
      <table width="80%" align="left">
	 	<c:choose>
	 		<c:when test="${listComment.size()==0}">
	 			<tr>
	      		<td colspan="6"> 暂无评论！ </td>
	      	</tr>
	        <tr>
	          	<td colspan="6"><hr /></td>
	        </tr>
	 		</c:when>
	 		<c:otherwise>
	 			<c:forEach items="${listComment}" var="c" >
	 		<tr>
	       		<td colspan="6">评论内容:<textarea  name="ncontent" id="ncontent" cols="100" rows="5" value="">${c.ccontent} </textarea> </td>
	      	</tr>
	      	<tr>
          	<td>评论者：${c.cauthor}</td>
          	<td>IP:${c.cip}</td>
          	<td>评论日期：${c.cdate}</td>
          	<td><a style="color:red" href='DeleteCommentServlet?cid=${c.cid}&nid=${news.nid}'>删除此条评论</a></td>
       		</tr>	
	      	<tr>
          	<td colspan="6"><hr /></td>
       		</tr>
       		<tr style="height:20px">
          	<td colspan="6"></td>
       		</tr>	
	 			</c:forEach>
	 		</c:otherwise>
	 	</c:choose>
      </table>
  </div>
</div>


<jsp:include page="/AdminFooterServlet"></jsp:include>
</body>
</html>